package com.bsoft.gol.hcs.satisfaction.dao;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import ctd.util.annotation.RpcService;
import com.bsoft.gol.hcs.satisfaction.entity.PatientSatisfactionSurveyAnswer;

import java.util.List;

public abstract class PatientSatisfactionSurveyAnswerDAO extends HibernateSupportDelegateDAO<PatientSatisfactionSurveyAnswer> {
    public PatientSatisfactionSurveyAnswerDAO() {
        this.setKeyField("surveyAnswerId");
    }

    @DAOMethod(sql = " from PatientSatisfactionSurveyAnswer where patientSurveyId =:patientSurveyId " +
            "and questionnaireId=:questionnaireId and titleId=:titleId ")
    public abstract PatientSatisfactionSurveyAnswer getSurveyAnswerBySqtId(@DAOParam("patientSurveyId") String patientSurveyId,
                                                                           @DAOParam("questionnaireId") String questionnaireId,
                                                                           @DAOParam("titleId") String titleId);

    @DAOMethod(sql = " update PatientSatisfactionSurveyAnswer set processingStatus='1' where surveyAnswerId =:surveyAnswerId ")
    public abstract void updatePendingStatusById(@DAOParam("surveyAnswerId") String surveyAnswerId);

    @DAOMethod(sql = " from PatientSatisfactionSurveyAnswer where patientSurveyId =:patientSurveyId and (processingStatus='1' or processingStatus='2') ")
    public abstract List<PatientSatisfactionSurveyAnswer> querySurveyAnswerBySurveyIdAndStatus(@DAOParam("patientSurveyId") String patientSurveyId);

    @DAOMethod(sql = " from PatientSatisfactionSurveyAnswer where patientSurveyId =:patientSurveyId and processingStatus='1' ")
    public abstract List<PatientSatisfactionSurveyAnswer> queryPendingSurveyAnswerBySurveyId(@DAOParam("patientSurveyId") String patientSurveyId);

    @DAOMethod(sql = " from PatientSatisfactionSurveyAnswer where patientSurveyId =:patientSurveyId ")
    public abstract List<PatientSatisfactionSurveyAnswer> querySurveyAnswerBySurveyId(@DAOParam("patientSurveyId") String patientSurveyId);

    @DAOMethod(sql = " delete from PatientSatisfactionSurveyAnswer where patientSurveyId =:patientSurveyId and questionnaireId=:questionnaireId")
    public abstract void deleteSurveyAnswerByPatientSurveyIdAndQuestionnaireId(@DAOParam("patientSurveyId") String patientSurveyId,
                                                                               @DAOParam("questionnaireId") String questionnaireId);

    //这个关于满意度调查的待处理的总数
    @RpcService
    @DAOMethod(sql = "select count(*) from PatientSatisfactionSurveyAnswer where " +
            "processingDoctorId=:processingDoctorId" +
            " and processingStatus='1'")
    public abstract Long getSatisfactionSurveyCount(@DAOParam("processingDoctorId") String processingDoctorId);
}